package tool;

import java.io.IOException;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class ExcelOption {

	private Workbook workbook;

	public ExcelOption() {
		super();
	}
	
	public Workbook getWorkbook()
	{
		return this.workbook;
	}
	
	private void setWorkbook(Workbook workbook)
	{
		this.workbook=workbook;
	}
	
	
	/**
	 * 
	 * @param filename
	 * @throws IOException the file can't be use 
	 */
	public ExcelOption(String filename) throws IOException
	{
		this.setWorkbook(this.getWorkBookByFileName(filename));
	}
	
	
	/**
	 * use this function to make a new workbook to implements a new workbook if
	 * the name contains the xls you will get a hhs if the name contains th xlsx
	 * you will get xhs
	 * @param fileame the file name
	 * @return depend on you filename 
	 * @throws IOException the file is not the support type
	 */
	public Workbook getWorkBookByFileName(String filename) throws IOException {
		if (filename.endsWith("xlsx")) {
			return new XSSFWorkbook();
		} else if (filename.endsWith("xls")) {
			return new HSSFWorkbook();
		} else {
			throw new IOException("the file can't be caculate");
		}
	}
	
	
	public void writeALine(int linenumber,Object ...objects)
	{
		
	}
	
	
	public void readALine(int linenumber,Object ...objects)
	{
		
	}
}
